import sys
# print(sys.path)  # 调试信息，检查Python模块路径

import rclpy
from rclpy.node import Node
from origincar_msg.msg import Sign  # 确保这个导入路径是正确的

class SignPublisher(Node):

    def __init__(self):
        super().__init__('sign_publisher')
        self.publisher_ = self.create_publisher(Sign, '/sign_switch', 10)
        timer_period = 1.0  # 发布频率为1秒
        self.timer = self.create_timer(timer_period, self.publish_message)

    def publish_message(self):
        msg = Sign()  # 创建一个Sign消息对象
        msg.sign_data = 3  # 设置sign_data的值为4，表示二维码数据为逆时针

        self.get_logger().info(f'Publishing: {msg.sign_data}')
        self.publisher_.publish(msg)  # 发布消息到/sign_switch话题

def main(args=None):
    rclpy.init(args=args)
    sign_publisher = SignPublisher()
    rclpy.spin(sign_publisher)  # 保持节点运行，直到被手动停止
    sign_publisher.destroy_node()
    rclpy.shutdown()

if __name__ == '__main__':
    main()
